HEX
Server: Apache/2.4.68 (Debian)
System: Linux as-cs-widget-demo-us-central1 6.1.0-44-cloud-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.164-1 (2026-03-09) x86_64
User: root (0)
PHP: 8.2.32
Disabled: NONE
Upload Files
File: /var/www/html/wp-content/plugins/wp-recipe-maker/assets/js/shared/Api/Idea.js
const ideaEndpoint = wprm_admin.endpoints.idea;
const ideaImportEndpoint = wprm_admin.endpoints.idea_import;

import ApiWrapper from '../ApiWrapper';

export default {
    get(id) {
        return ApiWrapper.call( `${ideaEndpoint}/${id}?t=${ Date.now() }` );
    },
    save(idea) {
        const data = {
            idea,
        };

        let url = ideaEndpoint;
        let method = 'POST';

        const ideaId = idea.id ? parseInt( idea.id ) : false;
        if ( ideaId ) {
            url += `/${ideaId}`;
            method = 'PUT';
        }

        return ApiWrapper.call( url, method, data );
    },
    updateStatus(ideaId, status) {
        const data = {
            idea: {
                status,
            },
        };

        return ApiWrapper.call( `${ideaEndpoint}/${ideaId}`, 'PUT', data );
    },
    delete(id, permanently = false) {
        let endpoint = `${ideaEndpoint}/${id}`;

        if ( permanently ) {
            endpoint += '?force=true';
        }

        return ApiWrapper.call( endpoint, 'DELETE' );
    },
    import(ideas) {
        return ApiWrapper.call( ideaImportEndpoint, 'POST', {
            ideas,
        } );
    },
};